# use Tkinter to show a digital clock
# tested with Python24    vegaseat    10sep2006

from Tkinter import *
import time
import socket


root = Tk()
time1 = ''
clock = Label(root, font=('times', 196, 'bold'), bg='blue')
data_rec=Label(root,font=('times', 196, 'bold'), bg='blue')
clock.pack(fill=BOTH, expand=1)
data_rec.pack(fill=BOTH,expand=1)



def recieve_data():
    global time1 
    UDP_IP="127.0.0.1"
    UDP_PORT=5053

    sock = socket.socket( socket.AF_INET, # Internet
                      socket.SOCK_DGRAM ) # UDP
    
          
    sock.bind( (UDP_IP,UDP_PORT) )

   
       # data_rec.config(text=data)
    # calls itself every 200 milliseconds
    # to update the time display as needed
    # could use >200 ms, but display gets jerky
    while True:
            data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
            print "received message:", data
            if data=="quit":       
                print "quittin"
                data_rec.config(text=data)
                sock.close()
                sys.exit
            else :
                print "continue"
                data_rec.config(text=data)
                time2 = time.strftime('%H:%M:%S')
                clock.config(text=time2)
        



  
    
    # get the current local time from the PC

        
recieve_data()
#root.mainloop()    

